package com.eloancn.leecode.sort;
/**
 *	 归并排序
 * @author lihepeng
 */


import org.junit.Test;

import java.util.HashMap;
import java.util.Map;


public class MergeSort {
	public void mergeSort(int [] arr,int left,int mid,int right) {
		int []tmp = new int [arr.length];
		int i =left;
		int j = mid+1;
		int k = 0;
		while(i<= mid && j <= right) {
			if(arr[i]<arr[j]) {
				tmp[k++] = arr[i++];
			}else {
				tmp[k++] = arr[j++];
			}
			while(i<=mid) {
				tmp[k++] =arr[i++];
			}
			while(j <= right) {
				tmp[k++] = arr[j++];
			}
			// 将temp 数组中的全部元素拷贝到原数组中
			for(int k2 = 0;k2<tmp.length;k2++) {
				arr[k2+left] = tmp[k2];
			}
			
		}
		
		
	}
	@Test
	public void runTest01() {
		Map<String, String> map = new HashMap<>();
		
	}
}
